
<%@ page language="java" contentType="text/html" 
    pageEncoding="UTF-8" %>
    
<%@ page import="javax.xml.transform.*" %>
<%@ page import="javax.xml.transform.stream.*" %>
<%@ page import="javax.xml.parsers.*" %>
<%@ page import="org.w3c.dom.*" %>
<%@ page import="java.io.*" %>
<%@ page import="java.net.URL" %>
<%@ page import="java.net.MalformedURLException" %>

<%@ page import="java.net.HttpURLConnection" %>



<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Donation</title>

<link rel="stylesheet" type="text/css" href="css/home.css"/>
<script type='text/javascript' src='http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js'></script>

  <script type='text/javascript' src='js/item.js'></script>
</head>
<body>
	<div id="header">
	  <div id="logo"></div>
	  <div id="navBar">
	  	<ul>	  
	  		<li class="current"><a href="index.jsp">Home</a></li>
	  		<li ><a  href="main.jsp?url=category&amp;xsl=home&amp;order=name">Category</a></li>
	  		<li><a href="main.jsp?url=theme&amp;xsl=theme&amp;order=title">Theme</a></li>	
	  		<li><a href="main.jsp?url=collection&amp;xsl=collection&amp;order=name">Collection</a></li>
	  	</ul>
	  	
	  </div>
	  	  
	  <hr />
  </div>
  <div id="mainContent">
  
  

<% 

  	

  String itemId = request.getParameter("item_id");
  URL url_item = new URL("http://api.powerhousemuseum.com/api/v1/item/" + itemId +"/xml/?api_key=90b0723f9926ce3");
  HttpURLConnection conn = (HttpURLConnection) url_item.openConnection();

  //Using xslt 
  Transformer transformer = TransformerFactory .newInstance().newTransformer(new StreamSource(application.getResourceAsStream("item.xsl")));	
  transformer.transform(new StreamSource(url_item.openStream()), new StreamResult(out));
  
  //InputStream file = conn.getInputStream();
  DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
  DocumentBuilder db = dbf.newDocumentBuilder();
  
  Document doc_item = db.parse(conn.getInputStream());
  
  /* Get multimedia url */
  NodeList multimediaList = doc_item.getElementsByTagName("multimedia_uri");
  Node multimedia = multimediaList.item(0).getFirstChild();
  String multimediaUri = multimedia.getNodeValue();
  URL url_multimedia = new URL("http://api.powerhousemuseum.com"+multimediaUri);
  
  HttpURLConnection conn_multimedia = (HttpURLConnection) url_multimedia.openConnection();
  Document doc_multimedia = db.parse(conn_multimedia.getInputStream());
  

  
  /* Get multimedia image url */
  String[] thumbnail_urls;
  int num_multimedia = Integer.parseInt(doc_item.getElementsByTagName("num_multimedia").item(0).getFirstChild().getNodeValue());

  NodeList multimedia_thumbnails = doc_multimedia.getElementsByTagName("thumbnail");
  
  out.println("<h3>Multimedia</h3>");
  for(int i=0; i<num_multimedia; i++)
  {  
	  thumbnail_urls = new String[num_multimedia];
	  
	  thumbnail_urls[i] =  multimedia_thumbnails.item(i).getFirstChild().getFirstChild().getNodeValue();
    
	  out.print("<img class='thumbnailImg' src="+thumbnail_urls[i]+" />");
  }
  
%>





	</div>
   </div>

  <hr />
  <div class="clearer"></div>
  <div id="footer">
 <p>All rights reserved. Developed by Pen Bang Inc. 2011</p> 
 </div>
 <div id="fadeBox">
     <div id="donationBox">
  		<form method="post" action="ccheck.jsp" id="ccheckForm">
		 	<p >Amount:  <input type="text" name="ccheck_amount" /><br /></p>
	 		<p >Card Name: <input type="text" name="ccheck_name" /> <br /></p>
	 		<p >Card Number:  <input type="text" name="ccheck_number" /> <br /></p>	
	 		<p>Card Type: <select name="ccheck_type"><option>Visa</option><option>MasterCard</option></select> <br /></p>
	 		<p >Expire Date:  <input type="text" name="ccheck_expdate" /> <br /></p>	
		 	<input type="submit" value="submit" id="donationSubmit"/>
		 	<input type="button" value="cancel" id="cancelButton"/>
 		</form>
  	</div>
 </div>
</body>
</html>


  
  

  
 


